<%@ Page Language="C#" MasterPageFile="~/MasterPageMcSigAdmin.master" AutoEventWireup="true"
    CodeFile="RubrosListado.aspx.cs" Inherits="RubrosListado" Title="Rubros" %>

<%@ Register Assembly="FUA" Namespace="Subgurim.Controles" TagPrefix="cc2" %>
<%@ Register Assembly="UsrControls" Namespace="UsrControls" TagPrefix="cc1" %>
<%@ Register Assembly="Anthem" Namespace="Anthem" TagPrefix="anthem" %>
<%@ Register Assembly="DevExpress.Web.v12.2, Version=12.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.v12.2, Version=12.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.v12.2, Version=12.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <h1 class="presupuesto">
        Rubros</h1>
    <anthem:Label ID="lblMensaje" runat="server" AutoUpdateAfterCallBack="True" UpdateAfterCallBack="True"></anthem:Label>
    <anthem:TextBox ID="txtidUsuario" runat="server" AutoUpdateAfterCallBack="True" Visible="False">8</anthem:TextBox>
    <p class="bt-space15">
        <asp:Label ID="lblInstruccion" runat="server" CssClass="instruccion" Text="Para actualizar informacion de un Rubro seleccione un registro en la primera columna y pulse el boton ACTUALIZAR, para borrar informacion seleccione uno o varios registros y pulse el boton ELIMINAR. Si desea ingresar un Perfil pulse el boton AGREGAR."></asp:Label></p>
    <cc1:WccAcciones ID="WccAcciones1" runat="server" CssClass="toolbar" AddCausesValidation="False"
        AddEnableCallBack="False" ArchiveVisible="False" AuditVisible="False" DeclineVisible="False"
        DeleteEnableCallBack="True" DeletePreCallBackFunction="delete_PreCallBack" OnAdd_OnClick="WccAcciones1_Add_OnClick"
        OnDelete_OnClick="WccAcciones1_Delete_OnClick" OnUpdate_OnClick="WccAcciones1_Update_OnClick"
        PublishVisible="False" UpdateCausesValidation="False" UpdateEnableCallBack="False"
        UpdateOnClickFunction="return confirmEdit();" ValidateVisible="False"></cc1:WccAcciones>
    <table class="tabs">
        <tr>
            <td class="tab-inactivo">
                <anthem:LinkButton ID="lnkRubro" runat="server" CausesValidation="False" EnableCallBack="False"
                    OnClick="lnkRubro_Click" OnClientClick="return confirmEdit();">Rubro</anthem:LinkButton>
            </td>
            <td id="td2" runat="server" class="tab-inactivo" visible="False">
                <anthem:LinkButton ID="lnkModificaciones" runat="server" CausesValidation="False"
                    EnableCallBack="False" Enabled="true" OnClick="lnkModificaciones_Click" OnClientClick="return confirmEdit();">Modificaciones</anthem:LinkButton>
            </td>
        </tr>
    </table>
    <anthem:Panel ID="Panel1" CssClass="bt-space15" runat="server" AutoUpdateAfterCallBack="True"
        Width="100%">
        <dxwgv:ASPxGridView ID="gridRubros" runat="server" Width="100%" KeyFieldName="PLN_ID"
            CssPostfix="PlasticBlue" CssFilePath="~/App_Themes/Plastic Blue/{0}/styles.css"
            AutoGenerateColumns="False" Theme="PlasticBlue">
            <Settings ShowFilterRow="True" ShowGroupPanel="True" ShowFooter="True" VerticalScrollableHeight="100"
                ShowFilterRowMenu="True" />
            <Styles CssFilePath="~/App_Themes/Plastic Blue/{0}/styles.css" CssPostfix="PlasticBlue">
                <Header ImageSpacing="10px" SortingImageSpacing="10px">
                </Header>
                <Customization Wrap="False">
                </Customization>
                <Table Wrap="False">
                </Table>
                <PreviewRow Wrap="False">
                </PreviewRow>
                <SelectedRow BackColor="Maroon">
                </SelectedRow>
                <Cell Wrap="True">
                </Cell>
                <CustomizationWindowContent Wrap="False">
                </CustomizationWindowContent>
                <LoadingPanel BackColor="#FFC0C0" Cursor="auto">
                </LoadingPanel>
                <LoadingDiv BackColor="White">
                </LoadingDiv>
            </Styles>
            <Columns>
                <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Width="5%">
                    <ClearFilterButton Text="Borrar Filtro" Visible="True">
                    </ClearFilterButton>
                </dxwgv:GridViewCommandColumn>
                <dxwgv:GridViewDataTextColumn FieldName="PLN_ID" Visible="False" VisibleIndex="1">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="Nombre" FieldName="PLN_NOMBRE" VisibleIndex="1"
                    Width="30%">
                    <Settings AutoFilterCondition="Contains" />
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="C&#243;digo presupuestal" FieldName="PLN_CODIGO_PRESUPUESTAL"
                    VisibleIndex="2" Width="10%">
                    <Settings AutoFilterCondition="Contains" />
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="Dependencia" FieldName="DEP_NOMBRE" VisibleIndex="3"
                    Width="10%">
                    <Settings AutoFilterCondition="Contains" />
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="Total Programado" FieldName="TOTAL_PROGRAMADO"
                    Visible="False" VisibleIndex="4" Width="15%">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="A&#241;o" FieldName="PLN_ANO" VisibleIndex="6"
                    Width="10%">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="Valor Apropiaci&#243;n" FieldName="PLN_VALOR_APROPIACION"
                    VisibleIndex="4" Width="15%">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="Clasificaci&#243;n de Gasto" FieldName="CLS_NOMBRE"
                    VisibleIndex="5" Width="15%">
                    <EditFormSettings RowSpan="1" />
                </dxwgv:GridViewDataTextColumn>
            </Columns>
            <TotalSummary>
                <dxwgv:ASPxSummaryItem DisplayFormat="{0:N2}" FieldName="PLN_VALOR_APROPIACION" ShowInGroupFooterColumn="Valor Apropiaci&#243;n"
                    SummaryType="Sum" />
            </TotalSummary>
            <SettingsPager ShowDefaultImages="False" AlwaysShowPager="True">
                <AllButton Text="Todos" ImagePosition="Right" Visible="True">
                </AllButton>
                <NextPageButton Text="Siguiente &gt;">
                </NextPageButton>
                <PrevPageButton Text="&lt; Anterior">
                </PrevPageButton>
            </SettingsPager>
            <SettingsText GroupPanel="Arrastre aqui las columnas que desea agrupar" Title="Usuarios" />
            <SettingsCookies Enabled="True" />
            <SettingsBehavior ColumnResizeMode="Control" />
        </dxwgv:ASPxGridView>
    </anthem:Panel>
    <aspxgridviewexporter id="gridExport" runat="server" gridviewid="gridRubros">
                </aspxgridviewexporter>
    <asp:Button ID="btnXlsExport" runat="server" CssClass="button l" OnClick="btnXlsExport_Click"
        Text="Exportar a XLS" /><asp:Button ID="btnRtfExport" CssClass="button l" runat="server"
            OnClick="btnRtfExport_Click" Text="Exportar a RTF" /><asp:Button ID="btnCsvExport"
                CssClass="button l" runat="server" OnClick="btnCsvExport_Click" Text="Exportar a CSV" />
    <script language="javascript" type="text/javascript">
        function OnGridSelectionChanged() {
            var counter = document.getElementById("selCount");
            if (counter != null)
                setInnerText(counter, ctl00_ContentPlaceHolder1_gridRubros.GetSelectedRowCount().toString());
            ctl00_ContentPlaceHolder1_gridRubros.GetSelectedFieldValues('FPR_ENTIDAD_TERRITORIAL_COFINANCION', OnGridSelectionComplete);
        }
        function OnGridSelectionComplete(values) {
            selList.BeginUpdate();
            selList.ClearItems();
            for (var i = 0; i < values.length; i++) {
                selList.AddItem(values[i]);
            }
            selList.EndUpdate();
        }
        function setInnerText(element, text) {
            if (typeof element.textContent != 'undefined') {
                element.textContent = text;
            }
            else if (typeof element.innerText != 'undefined') {
                element.innerText = text;
            }
            else if (typeof element.removeChild != 'undefined') {
                while (element.hasChildNodes()) {
                    element.removeChild(element.lastChild);
                }
                element.appendChild(document.createTextNode(text));
            }
        }

        function confirmEdit() {
            var counter = ctl00_ContentPlaceHolder1_gridRubros.GetSelectedRowCount();

            if (counter > 1) {
                counter = 0;
                alert("Debe seleccionar un solo registro");
                return (false);
            }
            else if (counter == 1) {
                counter = 0;
                return (true);
            }
            else if (counter == 0) {
                counter = 0;
                alert("Debe seleccionar al  menos un registro");
                return (false);
            }
        }
        function delete_PreCallBack(button) {
            var counter = ctl00_ContentPlaceHolder1_gridRubros.GetSelectedRowCount();

            if (counter > 0) {
                return confirm('Esta seguro de eliminar los registros seleccionados?')
            }
            alert("Debe seleccionar por lo menos un registro");
            return (false);

        }

        function confirmDelete() {
            var frm;

            if (arguments.length > 0) {
                frm = arguments[0];
            }
            else {
                frm = document.forms[0];
            }



            // loop through all elements
            for (i = 0; i < frm.length; i++) {
                // Look for our checkboxes only
                if (frm.elements[i].name.indexOf("chkId") != -1) {
                    // If any are checked then confirm alert, otherwise nothing happens
                    if (frm.elements[i].checked) {
                        return confirm('Esta seguro de eliminar los registros seleccionados?')
                    }
                }
            }
            alert("Debe seleccionar por lo menos un registro");
            return (false);
        }
    </script>
</asp:Content>
